package cn.tedu.oop;

/**
 * @program: HolidayHomework
 * @description:
 * @author: Zane Zhang
 * @create: 2022-06-05
 **/
public class ChineseMajor extends Major {
    //15.添加子类独有的属性:写作课成绩
    double writingScore;

    //16.生成子类自己的全参构造
    public ChineseMajor(double writingScore, double englishScore, double midScore, double finalScore) {
        //这里是在调用父类的构造方法,因为英文 期中 期末 成绩都是在父类那里赋值的
        super(englishScore, midScore, finalScore);
        //在子类的构造方法中只需要给子类的特有属性专业课成绩赋值即可
        this.writingScore = writingScore;
    }

    //17.子类重写父类的getScore(),具体实现总分数的计算
    @Override
    public double getScore() {
        //计算逻辑:总成绩=专业课成绩40%+英文课成绩10%+期中成绩15%+期末成绩35%
        totalScore = writingScore * 0.4 + englishScore * 0.1 + midScore * 0.15 + finalScore * 0.35;
        //返回计算好的成绩
        return totalScore;
    }

    //18.重写toString()方法,方便直接查看专业类的所有属性值
    @Override
    public String toString() {
        return "文学专业{" +
                "写作课成绩:" + writingScore +
                ",英文课成绩:" + englishScore +
                ",期中成绩:" + midScore +
                ",期末成绩:" + finalScore +
                '}';
    }
}

